﻿using System;
using System.Collections.Generic;
using System.Linq;
using Genuilder.Extensibility;

namespace Genuilder.Extensibility.Utilities
{
	public static class StringExtensions
	{
		public static String Substring(this String str, Location from, Location to)
		{
			return Location.GetTextBetween(from, to, str);
		}

		public static int IndexOf(this String str, Location location)
		{
			return Location.GetIndex(location, str);
		}

		public static String Reverse(this String str)
		{
			return new String(((IEnumerable<char>)str).Reverse().ToArray());
		}

		public static Location LocationOf(this String str, int index)
		{
			return Location.GetLocation(index, str);
		}
	}
}
